<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
	<meta charset="UTF-8">
	<title>基本设置</title>
	<link rel="stylesheet" href="/js/plugin/layui-v2.3.0/layui/css/layui.css">
	<link rel="stylesheet" href="/css/reset.css">
	<link rel="stylesheet" href="/css/index.css">
	<link rel="stylesheet" href="/css/project_set.css">
	<script src="/js/jquery-2.1.1.min.js"></script>
	<script src="/js/plugin/layui-v2.3.0/layui/layui.js"></script>
	<script src="/js/common.js"></script>
</head>
<style>
	body,html{
		height: auto; 
	}
	.my-line .layui-inline{
		vertical-align: top
	}
#testName2>dl{
	margin-right: 15px;
    margin-bottom: 15px;
    display:inline-block;
}
#testName2 .layui-upload-img{
	width:232px;height:134px
}
.img-del{
    position: absolute;
    text-align: center;
    line-height: 16px;
    display:none;
    top: -6px;
    right: -6px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    -o-border-radius: 50%;
    -ms-border-radius: 50%;
    -moz-border-radius: 50%;
    -webkit-border-radius: 50%;
    border: 1px solid #e6e6e6;
    background-color: #ffffff;
    cursor: pointer;
    font-weight:600;
}
#testName2>dl:hover .img-del{
	display:block
}
</style>
<body>
<input type="hidden" id="projectProvinceId" name="projectProvinceId" th:value="${projectInfo.projectProvince}" />
<input type="hidden" id="projectCityId" name="projectCityId" th:value="${projectInfo.projectCity}" />
<input type="hidden" id="projectRegionId" name="projectRegionId" th:value="${projectInfo.projectRegion}" />
	<div class="nav-section-content-container" style="padding: 0px">
					<header class="nav-header">
						<div class="nav-section-header-title">
							<span>基本设置</span>
						</div>
					</header>
					<div class="kb-form-container">
						<!-- <fieldset class="fieldset">
							<legend>客户端APP可见</legend>
							<form class="layui-form" action="" lay-filter="">
								<div>
									<div class="layui-form-item">
									    <div class="layui-input-inline" style="width:60px">
									      <input type="checkbox" name="switch" lay-skin="switch">
									    </div>
									    <span class="bottom-tip" >用户可以在客户端App或微信上看见此分店的基本信息和图片。</br>如果关闭，此分店信息仅对运营管理人员可见</span>
									 </div>
								</div>
							</form>
						</fieldset> -->
						<form class="layui-form" id="defaultForm" th:action="@{/app/project/update}" th:method="post" lay-filter="employee-form">
						<fieldset class="fieldset">
							<legend>基本信息</legend>
								<input type="hidden" id="id" name="id" th:value="${projectInfo.id}" />
								<div>
									<div class="layui-form-item">
									    <div class="layui-inline">
										    <label class="layui-form-label"><span class="must-fill">*</span>分店名称</label>
										        <div class="layui-input-inline" style="width: 370px;">
										            <input type="tel" name="projectName" autocomplete="off" class="layui-input" placeholder="" th:value="${projectInfo.projectName}">
										        </div>
									    </div>
									     <div class="layui-inline">
										        <label class="layui-form-label text-r">编号</label>
										        <div class="layui-input-inline" style="width: 180px;">
										            <input type="tel" name="projectNumber" autocomplete="off" class="layui-input" placeholder="" th:value="${projectInfo.projectNumber}">
										        </div>
									     </div>
									</div>
									<div class="layui-form-item">
									    <div class="layui-inline">
										    <label class="layui-form-label"><span class="must-fill">*</span>省份</label>
										        <div class="layui-input-inline" style="width: 180px;">
										           	<select name="projectProvince" id="projectProvince" onchange="" lay-filter="projectProvince" required  lay-verify="projectProvince">
			       
			      									</select>
										        </div>
									    </div>
									    <div class="layui-inline">
										        <label class="layui-form-label" style="width: 36px;"><span class="must-fill">*</span>城市</label>
										        <div class="layui-input-inline" style="width: 170px;">
										            <select name="projectCity" id="projectCity" lay-filter="projectCity" required  lay-verify="projectCity">
			       
			      									</select>
										        </div>
									    </div>
									    <div class="layui-inline">
										        <label class="layui-form-label" style="width: 22px;"><span class="must-fill">*</span>区</label>
										        <div class="layui-input-inline" style="width: 170px;">
										            <select name="projectRegion" id="projectRegion" lay-filter="projectRegion" required  lay-verify="projectRegion">
			       
			      									</select>
										        </div>
									    </div>
									</div>
									<div class="layui-form-item layui-form-text">
									    <label class="layui-form-label"><span class="must-fill">*</span>地址</label>
									    <div class="layui-input-block" style="padding-right: 25px">
									      <textarea placeholder="请输入内容" class="layui-textarea" name="projectAddress" lay-verify="projectAddress" th:text="${projectInfo.projectAddress}">西坝河南路一号金泰大厦5层</textarea>
									    </div>
									</div>
									<div class="layui-form-item my-line">
									    <div class="layui-inline">
										    <label class="layui-form-label">电话</label>
										        <div class="layui-input-inline" style="width: 182px;">
										           	<input type="tel" name="projectTelephone" autocomplete="off" th:value="${projectInfo.projectTelephone}" class="layui-input" placeholder="">
										        </div>
									    </div>
									    <div class="layui-inline">
										        <label class="layui-form-label" style="width: 36px;"><span class="must-fill">*</span>面积</label>
										        <div class="layui-input-inline" style="width: 160px;">
										            <input type="tel" name="projectArea" lay-verify="projectArea" autocomplete="off" th:value="${projectInfo.projectArea}" class="layui-input" placeholder="">
										        </div>
									    </div>
									    <div class="layui-inline">
										        <label class="layui-form-label" style="width: 42px;">排序位</label>
										        <div class="layui-input-inline" style="width: 160px;">
										            <input type="tel" name="sortNumber" autocomplete="off"  th:value="${projectInfo.sortNumber}" class="layui-input" placeholder="">
										            <p class="bottom-tip" style="margin-bottom: 0px">请输入数字，修改客户端的社区位置，数字越大排上面</p>
										        </div>

									    </div>
									</div>
								</div>
							</fieldset>
						<fieldset class="fieldset">
							<legend>甲方信息</legend>
								<div>
									<div class="layui-form-item">
									    <label class="layui-form-label">名称</label>
									    <div class="layui-input-block">
									      <input type="text" name="partyName" lay-verify="title" autocomplete="off" th:value="${projectInfo.partyName}" placeholder="" class="layui-input">
									    </div>
									</div>
									<div class="layui-form-item">
									    <label class="layui-form-label">地址</label>
									    <div class="layui-input-block">
									      <input type="text" name="partyAddress" lay-verify="title" autocomplete="off" th:value="${projectInfo.partyAddress}" placeholder="" class="layui-input">
									    </div>
									</div>
									<div class="layui-form-item">
									    <label class="layui-form-label">开户行</label>
									    <div class="layui-input-block">
									      <input type="text" name="partyOpening" lay-verify="title" autocomplete="off" th:value="${projectInfo.partyOpening}" placeholder="" class="layui-input">
									    </div>
									</div>
									<div class="layui-form-item">
									    <label class="layui-form-label">账号</label>
									    <div class="layui-input-block">
									      <input type="text" name="partyAccount" lay-verify="title" autocomplete="off" th:value="${projectInfo.partyAccount}" placeholder="" class="layui-input">
									    </div>
									</div>
									<div class="layui-form-item">
									    <label class="layui-form-label">联系电话</label>
									    <div class="layui-input-block">
									      <input type="text" name="partyTelephone" lay-verify="title" autocomplete="off" th:value="${projectInfo.partyTelephone}" placeholder="" class="layui-input">
									    </div>
									</div>
									
								</div>
							</fieldset>
						
						<fieldset class="fieldset">
							<legend>上传分店图片</legend>
							<form class="layui-form" action="" lay-filter="">
								<div class="flex">
									<div id="testName2">
										<dl th:if="${projectInfo.attachment!=null}" th:id="${projectInfo.attachment.id}" >
							    			<dt style="position: relative;">
							    				<img th:src="|${projectInfo.attachment.filePath}${projectInfo.attachment.id}${projectInfo.attachment.fileType}|" class="layui-upload-img">
							    				<div class="img-mask"></div>
							    				<span class="img-del" th:id="${projectInfo.attachment.id}" onclick="delt(this)"><i class="glyphicon glyphicon-trash">×</i></span>	
							    			</dt>
							    			<dd style="padding-right:10px;line-height:16px">
							    				<input type="hidden" id="fileId" name="fileId" th:value="${projectInfo.attachment.id}" />
									    		
							    			</dd>
								    	</dl>
									</div> 
									<div class="flex-vcenter" style="align-items: flex-start">
										<button type="button" class="layui-btn layui-btn-normal layui-btn-radius" id="test2">上传图片</button>
										<p class="bottom-tip">图片格式为png或jpg,尺寸大小不小于200x150,文件大小不大于1M</p>
									</div>
									<input type="hidden" id="sysAttachmentPortraitId" name="sysAttachmentPortraitId" />
									
								</div>	
								<div class="layui-form-item">
									<button class="layui-btn layui-btn-normal btn-bg" lay-submit lay-filter="formEmployee" id="submit-btn">保存</button>
								</div>
							</form>
						</fieldset>
						</form>
					</div>
				</div>
</body>
<script>
$(function(){
	setHeight();
	initFormSelects("projectProvince","/system/province/selectjson/0_",$("#projectProvinceId").val());
	initFormSelects("projectCity","/system/province/selectjson/1_"+$("#projectProvinceId").val(),$("#projectCityId").val());
	initFormSelects("projectRegion","/system/province/selectjson/2_"+$("#projectCityId").val(),$("#projectRegionId").val());
    layui.config({
        base: '/js/plugin/layui-v2.3.0/layui/' //此处路径请自行处理, 可以使用绝对路径
    }).extend({
        formSelects: 'formSelects-v3'
    }).use(['element',"layer","form",'formSelects','upload'], function(){
		var layer=layui.layer,form = layui.form,formSelects = layui.formSelects,upload = layui.upload;
		form.on('select(projectProvince)', function(data){
			initFormSelects("projectCity","/system/province/selectjson/1_"+data.value,"");
		});
		form.on('select(projectCity)', function(data){
			initFormSelects("projectRegion","/system/province/selectjson/2_"+data.value,"");
			//form.render('select')
		});
		//上传
		layui.use('upload', function(){
			var $ = layui.jquery
			,upload = layui.upload;
			
			upload.render({
			    elem: '#test2'
			    ,url: "/common/upload/add/"+$("#id").val()
			    ,size: 0
			    ,accept: 'file' //普通文件
			    ,done: function(res, index, upload){
			      //上传完毕
			      	//layer.msg("只能上传一个文件，再次上传将覆盖！");
			    	$("#sysAttachmentPortraitId").val(res.id);
			    	$('#testName2').html('<dl id="'+res.id+'"><dt style="position: relative;"><img src="'+ res.sqlPath + res.id + res.extName +'" class="layui-upload-img"><div class="img-mask"></div><span class="img-del" id="'+res.id+'" onclick="delt(this)"><i class="layui-icon">&#x1006;</i></span></dt><dd style="padding-right:10px;line-height:16px"><input type="hidden" id="fileId" name="fileId" value="'+res.id+'" /><div class="img-tip"></div></dd></dl>')
			    	setHeight();
			    }
		  });
		});
		
		form.verify({
			projectName: function(value, item){ //value：表单的值、item：表单的DOM对象
	      	  if(value==""){
		       	  return '分店名称不能为空';
		      }
		  }
			,projectProvince: function(value, item){ //value：表单的值、item：表单的DOM对象
	      	  if(value==""){
		       	  return '省份不能为空';
		      }
		  }
			,projectCity: function(value, item){ //value：表单的值、item：表单的DOM对象
	      	  if(value==""){
		       	  return '城市不能为空';
		      }
		  }
		  ,projectAddress: function(value, item){ //value：表单的值、item：表单的DOM对象
	      	  if(value==""){
		       	  return '地址不能为空';
		      }
		  }
		  ,projectArea: function(value, item){ //value：表单的值、item：表单的DOM对象
		    if(value==""){
		    	return '面积不能为空';
		    }else if(!new RegExp("^\\d+(\\.\\d+)?$").test(value)){
		      return '面积不能有特殊字符';
		    }
		  }
		  ,introduction: function(value, item){ //value：表单的值、item：表单的DOM对象
		     if(value==""){
		     	return '简介不能为空';
		     }
		  }
		  
		  
		}); 
		//监听提交
		  form.on('submit(formEmployee)', function(data){
			  $.post($("#defaultForm").attr('action'), data.field, function(result) {
					layer.msg(result.msg);
				}, 'json');
				return false;
		  });
		
	});
})

function setHeight(){
    var h = document.body.clientHeight;
    window.parent.setiframeWrap(h);
}
</script>
</html>